<?php
//$userInfo = $usrObj->getMemberById($userId);
$userInfo=mysql_fetch_array(mysql_query("select * from tbl_users where user_id='".$_SESSION['user_id_sess']."'"));
if($userInfo['set_api']=='No')
{
echo '<script>window.location.href="index.php?amazon_land";</script>';
}
else
{
?>
<script src="<?php echo $base_url?>js/jquery-1.4.4.js" type="text/javascript"></script>
<script src="<?php echo $base_url?>js/jquery.custom_radio_checkbox.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
	$(".radio").dgStyle();
	$(".checkbox").dgStyle();
});
</script>
<?php
require_once 'includes/image_resizer.php'; 
require_once "includes/class/member_management.class.php";

$smsg="";
/*if($_SESSION['user_id_sess']=="") {
	echo "<script type='text/javascript'> window.location='index.php?signin&url=sell'; </script>";
}
*/
$userId = $_SESSION['user_id_sess'];	
$usrObj = new member_management;

$userType = $_SESSION['user_type_sess'];

if((int)$userType==2 || (int)$userType==4)
{
	$sqlComm_Token="SELECT * FROM tbl_users where user_id ='".$_SESSION['user_id_sess']."' ";
	$rstComm_Token=mysql_query($sqlComm_Token);
	$rowComm_Token=mysql_fetch_array($rstComm_Token);
	if(is_array($rowComm_Token))
	{
		if($rowComm_Token['comm_tokenID']=="")
		{
			echo "<script type='text/javascript'> window.location='index.php?amazon_land'; </script>";
		}
	}
}
		


if(isset($_REQUEST['keyword']))
{
	
	$today			=	date("Y-m-d G:i:s",time());
	$duration		=	30;
	$bargainDuration 	= 	date("Y-m-d G:i:s",time() + ($duration * 24 * 60 * 60));		
	
	$bargain_price_option	=	sanitize($_REQUEST['bargain_price_option']);
	$localPickup		=	sanitize($_REQUEST['localPickup']);
	$bargain_commission_option = 	sanitize($_REQUEST['bargain_commission_option']);
	$amazon_name		=	sanitize($_REQUEST['amazon_name']);
	$gift_name 		=	sanitize($_REQUEST['gift_name']);
	$gift_description	=	sanitize($_REQUEST['gift_description']);
	//$gift_image		=	$_REQUEST['gift_image'];
	
	$pro_name		=	sanitize($_REQUEST['pro_name']);	
	$category		=	"";
	$pro_quantity		=	sanitize($_REQUEST['pro_quantity']);
	
	$sell_by		=	sanitize($_REQUEST['sell_by']);
	$pro_condition 		= 	sanitize($_REQUEST['pro_condition']);
	$pro_commission 	= 	sanitize($_REQUEST['pro_commission']);
	$pro_commission		=	str_replace("$","",$pro_commission);
	$shipStatus		=	sanitize($_REQUEST['ship_status']);
	//$ship_service		=	$_REQUEST['ship_service'];
	
	$pro_shipping		=	sanitize($_REQUEST['pro_shipping']);
	$pro_policy		=	sanitize($_REQUEST['pro_policy']);
	$pro_courior		=	sanitize($_REQUEST['pro_courior']);
	$sales_tax		=	sanitize($_REQUEST['sales_tax']);
	
	if($shipStatus) {
		$shipping 	= 	"Free";
	}
	else {
		$shipping 	= 	sanitize($_REQUEST['pro_ship']);
		$shipping	=	str_replace("$","",$shipping);
	}
	
	if($_REQUEST['pro_sub_subcategory']!="") {
		$category	=	sanitize($_REQUEST['pro_sub_subcategory']);
	}
	else {
		$category	=	sanitize($_REQUEST['pro_subcategory']);
	}	
	
	$pro_price		=	sanitize($_REQUEST['pro_price']);	
	$pro_price		=	str_replace("$","",$pro_price);
		
	$pro_description	=	$_REQUEST['pro_description'];	
	$remarks		=	sanitize($_REQUEST['remarks']);
	
	if($localPickup==1)
		$sell_type	=	"local";
	else if($localPickup==1 && $shipping!='')
		$sell_type	=	"both";
	else
		$sell_type	=	"online";
	
	$sql_addpro="INSERT INTO tbl_product set product_name='$pro_name',
				category_id='$category',
				product_price='$pro_price',
				commission='$pro_commission',
				bargain_price_option='$bargain_price_option',
				localPickup='$localPickup',
				bargain_commission_option='$bargain_commission_option',
				gift_name='$gift_name',
				gift_description='$gift_description',
				bargain_amount='$pro_bargain',
				product_description='$pro_description',
				remarks='$remarks',
				quantity='$pro_quantity',
				shipping='$shipping',
				sales_tax='$sales_tax',
				selling_type='$sell_type',
				sell_by='$sell_by',
				pro_condition='$pro_condition',
				posted_by='$userId',
				return_id='$pro_policy',
				shipping_id='$pro_shipping',
				courior_id='$pro_courior',
				posted_date='$today'";
	$rst_addpro=mysql_query($sql_addpro);
	$pro_id=mysql_insert_id();
	
	 $subject="Product Listed Successfully";
	 $sqlEmail="select * from tbl_emails where email_type='Product Upload'";
	 $resEmail=mysql_query($sqlEmail);
	 $rowEmail=mysql_fetch_array($resEmail);
	 
	 $selUser=mysql_fetch_array(mysql_query("select * from tbl_users where user_id='".$userId."'"));
	 $fullname=$selUser['first_name']." ".$selUser['last_name'];
	 
	 $message=str_replace('%fname%',$selUser['first_name'],str_replace('%lname%',$selUser['last_name'],str_replace('%pname%',$pro_name,str_replace('%pro_quantity%',$pro_quantity,str_replace('%pro_shipping%',$pro_shipping,str_replace('%commission%',$pro_commission,str_replace('%pro_condition%',$pro_condition,str_replace('%pro_price%',$pro_price,$rowEmail['email_body']))))))));
	 $headers = "From: Swapen.com<mail@swapen.com> \r\n";
	 $headers .= 'MIME-Version: 1.0' . "\r\n";
	 $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	 mail($selUser['email'],$subject, $message, $headers);
	
	
	$upd_user=mysql_query("UPDATE tbl_users set amazon_email='$amazon_name' where user_id='".$_SESSION['user_id_sess']."'") or die(mysql_error());
	
	if($rst_addpro) {
		$smsg="true";
		
		$sqlInsImg = "INSERT INTO tbl_product_images SET product_id='$pro_id', product_type='p'";
		$rstInsImg = mysql_query($sqlInsImg);
		$pro_img_id = mysql_insert_id();
		
		
		//gift image
		$gift_image=pathinfo($_FILES["gift_image"]["name"]);	
		if(!empty($gift_image['extension'])) {
			if(strtolower($gift_image['extension'])=="jpeg" || strtolower($gift_image['extension'])=="jpg" || strtolower($gift_image['extension'])=="png" || strtolower($gift_image['extension'])=="gif") {
				$orgname1=mt_rand();				
				$type1=$gift_image['extension'];				
				$path1="products/original/".$orgname1.$pro_id.".".$type1;								
				
				$path_thumb1="products/thumb/".$orgname1.$pro_id."_thumb.".$type1;						
				
				$path_medium1="products/medium/".$orgname1.$pro_id."_medium.".$type1;				
				
				move_uploaded_file($_FILES["gift_image"]["tmp_name"],$path1);				  
				productResize($path1, $path_thumb1, $path_medium1, $type1);	
				$imagePath1 = 	$path1;
			}
			$ql = mysql_query("UPDATE tbl_product SET gift_image='$path1' WHERE product_id=$pro_id") or die(mysql_error);
		}
		
		
		
		for($i=1; $i<=5;$i++) {
			$pro_image[$i]=pathinfo($_FILES["pro_image".$i]["name"]);	
			
			if(!empty($pro_image[$i]['extension'])) {
				if(strtolower($pro_image[$i]['extension'])=="jpeg" || strtolower($pro_image[$i]['extension'])=="jpg" || strtolower($pro_image[$i]['extension'])=="png" || strtolower($pro_image[$i]['extension'])=="gif") {
											
					$orgname[$i]=mt_rand();				
					$type[$i]=$pro_image[$i]['extension'];				
					$path[$i]="products/original/".$orgname[$i].$pro_id.".".$type[$i];								
					
					$path_thumb[$i]="products/thumb/".$orgname[$i].$pro_id."_thumb.".$type[$i];						
					
					$path_medium[$i]="products/medium/".$orgname[$i].$pro_id."_medium.".$type[$i];				
					
					move_uploaded_file($_FILES["pro_image".$i]["tmp_name"],$path[$i]);				  
					productResize($path[$i], $path_thumb[$i], $path_medium[$i], $type[$i]);	
					$imagePath[] = 	$path[$i];	
					$mediumPath[] = $path_medium[$i];	
					$thumbPath[] = 	$path_thumb[$i];	
					$sql_updpro="UPDATE tbl_product_images set list_type='1',
							product_thumbnail_$i='".$path_thumb[$i]."',
							product_sample_$i='".$path_medium[$i]."',
							product_image_$i='".$path[$i]."'
							where product_image_id=$pro_img_id";	
					$rst_updpro=mysql_query($sql_updpro) or die(mysql_error());
					if(!$rst_updpro) { $smsg="false"; }	
				}
			}
	
		} //end of for
		
		
	   if(($_SESSION['user_type_sess']==2 || $_SESSION['user_type_sess']==4 )&& $sell_by==1)
		{
		$sqlInsItem = "INSERT INTO tbl_items SET 
					   product_id='$pro_id', 
					   category_id='$category',
					   seller_id='$userId', 
					   owner_id='$userId', 
					   owner_type=".$_SESSION['user_type_sess'].", 
					   price='$pro_price', 
					   product_description='$pro_description',
					   remarks='$remarks',
					   quantity='$pro_quantity',
					   status='1', 
					   bargain_duration='$bargainDuration',
					   created_date='$today'";
		$rstInsItem = mysql_query($sqlInsItem);
		$item_id=mysql_insert_id();
		$sqlSelImage="SELECT * FROM tbl_product_images where product_id ='$pro_id' AND product_type='p'";
		$rstSelImage=mysql_query($sqlSelImage);
		$rowSelImage=mysql_fetch_array($rstSelImage);
		$sqlInsImg = "INSERT INTO tbl_product_images SET 
		product_id='$item_id',
		product_type='i',
		product_image_1 ='".$rowSelImage['product_image_1']."'	,
		product_image_2 ='".$rowSelImage['product_image_2']."'	,	
		product_image_3 ='".$rowSelImage['product_image_3']."'	, 	
		product_image_4 ='".$rowSelImage['product_image_4']."'	, 	
		product_image_5 ='".$rowSelImage['product_image_5']."'	, 	
		product_sample_1 ='".$rowSelImage['product_sample_1']."'	, 	
		product_sample_2 ='".$rowSelImage['product_sample_2']."'	, 	
		product_sample_3 ='".$rowSelImage['product_sample_3']."'	, 	
		product_sample_4  ='".$rowSelImage['product_sample_4']."'	,	
		product_sample_5  ='".$rowSelImage['product_sample_5']."'	,	
		product_thumbnail_1 ='".$rowSelImage['product_thumbnail_1']."'	, 	
		product_thumbnail_2 ='".$rowSelImage['product_thumbnail_2']."'	, 	
		product_thumbnail_3 ='".$rowSelImage['product_thumbnail_3']."'	, 	
		product_thumbnail_4 ='".$rowSelImage['product_thumbnail_4']."'	, 	
		product_thumbnail_5 ='".$rowSelImage['product_thumbnail_5']."'";
		$rstInsImg = mysql_query($sqlInsImg);
		}
		
		//code
		$quan=(int)$pro_quantity;
		$sqlInsItem = "INSERT INTO tbl_items_code(code,product_id,item_id,owner_id,isSold,sell_by) VALUES ";
		for($i=1;$i<=$quan;$i++)
		{
			if($i==$quan)
			{
				$sqlInsItem .="(".rand(1000000000,9999999999).",'$pro_id','$item_id',".$_SESSION['user_id_sess'].",'0',0)";
			}
			else
			{
				$sqlInsItem .="(".rand(1000000000,9999999999).",'$pro_id','$item_id',".$_SESSION['user_id_sess'].",'0',0),";
			}
		}
		$rstInsItem = mysql_query($sqlInsItem);
		
		$sales_tax=$_REQUEST['sales_tax'];
		$quan=count($sales_tax);
		
		/*$sqlInsItem = "INSERT INTO tbl_sale_tax(state_id,product_id,sale_tax_amt) VALUES ";
		$i=1;
		while (list($key, $value) = each($state)) 
		{
			if($i==$quan)
			{
				$sqlInsItem .="('$key','$pro_id','$value')";
			}
			else
			{
				$sqlInsItem .="('$key','$pro_id','$value'),";
			}
			$i++;
		}
		$rstInsItem = mysql_query($sqlInsItem);
		*/
		//print_r($_REQUEST['state'])."<br/>";
		//echo $sqlInsItem;
		
	}
	else { $smsg="false"; }	
	
	
}

$amazonaccnt="";

if($userInfo['amazon_email']!="")
 $amazonaccnt=$userInfo['amazon_email'];

//echo rand(1000000000,9999999999);

?>
<style type="text/css">
	#sell-form { border:0px solid #CCC; vertical-align:top; padding:10px; float:left; width:93%; margin:2%; }

	#sell-form label{
	float: left;
	width: 130px;
	font-weight: bold;
	}
	
	#sell-form input, select, textarea{	
	width: 280px;
	margin-bottom: 5px;
	font-size:12px;
	}
	
	#sell-form textarea{
	height: 250px;
	width: 450px;
	font-size:12px
	}
	

	#sell-form #submitbutton{
	margin-left: 130px;
	margin-top: 5px;
	width: 90px;
	}
	
	#sell-form #sellby-div { float:left;  }
	
	#sell-form #sellby-div label { width: 70px; margin-bottom:2px; font-weight:normal; }
	#sell-form #sellby-div input { width: 1px; }
	
	#sell-form br{
	clear: left;
	}

	.whitebox950 {
		float:left;
		width:950px;
	}
	
	.whitebox940_top {
		background: url(images/whitebox_top_940.png) no-repeat scroll 0 0 transparent;
		float: left;
		height: 36px;
		margin: 0;
		padding: 0;
		width: 940px;
	}
	
	.whitebox940_bottom {
		background: url(images/whitebox_bottom_940.png) no-repeat scroll 0 0 transparent;
		float: left;
		height: 36px;
		margin: 0;
		padding: 0;
		width: 940px;
	}
	
	.whitebox940_repeat {
		background: url(images/whitebox_repeat_940.png) repeat-y scroll 0 0 transparent;
		float: left;
		margin: 0;
		padding: 0;
		width: 940px;
		
	}
	
	.blue_box_big {
	float:left;
	width:935px;
	margin: 0px 0px 0px 3px;
	}
	.bluebar_left_big {
	background:url(images/register_images/bluebar_left.png) no-repeat;
	width:19px;
	height:52px;
	float:left;
	margin:0px 0px 0px 0px;
	padding:0;
	}
	.bluebar_center_big {
	background:url(images/register_images/bluebar_repeat.png) repeat-x;
	height:52px;
	width:895px;
	float:left;
	text-align:center;
	
	}
	
	.bluebar_right_big {
	background:url(images/register_images/bluebar_right.png) no-repeat;
	width:19px;
	height:52px;
	float:left;
	}
	
	.bluebar_center_big span {
	float: left;
	padding: 15px 0px 15px 0px;
	width: 895px;
	}
	
	.form_field_big {
	float: left;
	/*height: 40px;*/
	padding: 7px;
	width: 870px;
	}
	
	.form_field_big a {
		text-decoration:none;
	}
	
	.form_field_big label {
	color: #666666;
	float: left;
	padding: 6px 3px 6px 0;
	text-align: left;
	width: 150px;
	font-weight:bold;
	}
	
	.inner_round_box {
		float: left;
		margin: 5px 18px;
		width: 96%;
		border: 1px solid #b5b5b5; -moz-border-radius: 7px 7px 7px 7px;
	}
	
	.btn_uplimg_left {
		width:10px;
		height:36px;
		background:url(images/button_left_07.png) no-repeat;
		float:left;
	}
	
	.btn_uplimg_repeat {
		float:left;
		height:36px;
		background:url(images/button_repeat_07.png) repeat-x;
	}
	
	.btn_uplimg_right {
		width:10px;
		height:36px;
		background:url(images/button_right_07.png) no-repeat;
		float:left;
	}
</style>
<div id='panel'>
	<a name="sprd" id="sprd"></a>
<table width="100%" border="0">
<?php
if($_SESSION['user_id_sess']!="") {
		if(empty($userInfo['tokenID'])){ ?>
		<tr>
			<td><!--<div>Sorry your tokenID to receive Payments from Swapen is not set yet, please go to Edit Profile (click Profile link at the top-right corner of the page) and hit submit and follow the steps to set up your token ID for Selling products in Swapen. </div>--><?php /*echo '<script>window.location.href="index.php?amazon_land";</script>';*/?></td>
		</tr>
	  <?php }
		else { ?>
			<tr>
			      <td><?php if($smsg=="true") { echo "<div id='suc-msg'> Product inserted successfully. </div>"; } ?></td>
			</tr>
			<?php
			//check "Your items being sold" is lessthan or equal to 100 and sell_by=1
			$sqlChkItems = "SELECT COUNT(*) FROM tbl_product where posted_by='$userId' and sell_by=1";
			$rstChkItems = mysql_query($sqlChkItems) or die(mysql_error());
			$rowChkItems = mysql_fetch_array($rstChkItems);
			
			if($rowChkItems[0]>=100 && $_GET['by']=='seller') {
				echo "<div id='err-msg' style='font-size:15px; font-weight:bold;'> Your selling items limit exceeded. You couldn't sell more than 100 items. </div>";
			}
			else {
			?>
		<tr>
		<td>
		<form name="form1" id="form1" method="post" action="" enctype="multipart/form-data"  onsubmit="return validateForm();">
			<div class="whitebox950" style="margin:0px 0px 0px 4px;">
				<div class="fullbox2_top"></div>
				<div class="fullbox2_repeat">
					<div class="blue_box_big" align="center">
						<img src="<?php echo $base_url;?>images/create_ur_product_listing.png" /><br />
						<font style="color:#B7B5B5;">Quickly and Easily post all your products here. </font>
						<br />&nbsp;
						<span style="float:left; text-align:right; width:97%;"><a href="javascript:void(0);" onclick="save_to_draft()">save for later</a> | <a href="javascript:void(0);" onclick="show_helpBox1()" id="help">help</a></span>
					</div>
					
					<div class="blue_box_big">
						<div class="bluebar_left_big"></div>
						<div class="bluebar_center_big"><span>Choose Category</span></div>
						<div class="bluebar_right_big"></div>
					</div>
					
					<div class="inner_round_box">
						<div class="form_field_big">
							<label for="pro_subcategory" id="lblpro_subcategory">Category</label>
							<?php
							//echo "select draft_id,draft_name,product_name from tbl_drafts where posted_by='".$_SESSION['user_id_sess']."' order by draft_id desc limit 100";
							$sql=mysql_query("select draft_id,draft_name,product_name from tbl_drafts where posted_by='".$_SESSION['user_id_sess']."' order by draft_id desc limit 100") or die(mysql_error());
							//echo "select draft_id,draft_name,product_name from tbl_drafts where posted_by='".$_SESSION['user_id_sess']."' order by draft_id desc limit 100";
							$cnt_sql = mysql_num_rows($sql);
							if($cnt_sql==0)
							{
								$display='none';
								$option='';
							}
							else {
								$display='block';
								$option='<option value="">Saved Drafts</option>';
								while($row = mysql_fetch_array($sql))
								{
									$option.='<option value="'.$row['draft_id'].'">'.$row['product_name'].'</option>';
								}
							}
							?>
							<div style="width:150px; float:right; display:<?php echo $display;?>;" id="draft_box">
								<select class="inputbg" style="width:150px;" id="saved_draft" onchange="applyDraft(this.value)">
									<?php echo $option; ?>
								</select>
							</div>
							<br /><br />
							<select class="inputbg" name="pro_subcategory" id="pro_subcategory" onChange="getSubSubCat(this.value,'sub-sub-category');">
							<option value="">..Select Category..</option>
							<?php				
							$sql_shocat="SELECT * FROM tbl_category where parent_id='1'";
							$rst_shocat=mysql_query($sql_shocat);
							while($row_shocat=mysql_fetch_array($rst_shocat)) {
								 $cat_id=$row_shocat['category_id'];
								 $cat_name=$row_shocat['category_name'];							 
								 echo "<option value='$cat_id'>$cat_name</option>";
							}
							?>
							</select>
							<span id="loader-div1"></span>
						</div>
						
						<div class="form_field_big" id="sub-sub-category">
							<label for="pro_sub_subcategory" id="lblpro_sub_subcategory">Sub Category</label><br /><br />
							<select class="inputbg" name="pro_sub_subcategory" id="pro_sub_subcategory">
								<option value="">..Select subcategory..</option>
							</select><br>
						</div>
					
					</div>
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>Buyers will locate your item better with a good descriptive listing name</b>
							<br />
							<label for="pro_name" id="lblpro_name">Listing Name</label><br /><br />
							<span>
								
								<input type="text" style="width: 400px;" class="inputbg" id="pro_name" name="pro_name" maxlength="45" />
								
							</span>
							<font style="font-size:10px; color:#636060;">
								<b>Re-called items:</b> It is solely your responsibility to make sure your item has not be recalled. If you are unsure please check <a href="http://www.recalls.gov" target="_blank">here</a>
							</font>
						</div>
					</div>
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>Add free images to make your listing stand out</b>
							<br /><br />
							<?php
							/*
							<div style="float:left; width:50px;">&nbsp;</div><!--This div is to give some blank space before button 1 starts-->
							
							<div style="float:left; margin-bottom:-10px; margin-right:10px;">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 1 <img src="images/success.gif" align="absmiddle" /></label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
							<div style="float:left; margin-bottom:-10px; margin-right:10px;">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 2</label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
							<div style="float:left; margin-bottom:-10px; margin-right:10px;">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 3</label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
							<div style="float:left; margin-bottom:-10px; margin-right:10px;">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 4</label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
							<div style="float:left; margin-bottom:-10px; margin-right:10px;">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 5</label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
							*/
							?>
							<label for="pro_image1">Product Image 1</label><br /><br /><br />
							<input type="file" name="pro_image1" id="pro_image1" class="inputbg" style="float:left;" />
						</div>
						<div class="form_field_big">
							<label for="pro_image2">Product Image 2</label><br /><br /><br />
							<input type="file" name="pro_image2" id="pro_image2" class="inputbg" style="float:left;" />
						</div>
						<div class="form_field_big">
							<label for="pro_image3">Product Image 3</label><br /><br />
							<input type="file" name="pro_image3" id="pro_image3" class="inputbg" style="float:left;" />
							
						</div>
						<div class="form_field_big">
							<label for="pro_image4">Product Image 4</label><br /><br /><br />
							<input type="file" name="pro_image4" id="pro_image4" class="inputbg" style="float:left;" />
						</div>
						<div class="form_field_big">
							<label for="pro_image5">Product Image 5</label><br /><br /><br />
							<input type="file" name="pro_image5" id="pro_image5" class="inputbg" style="float:left;" />
						</div>
					</div>
					
					<div class="inner_round_box">
						<script type="text/javascript" src="<?php echo $base_url;?>js/jHtmlArea/scripts/jquery-ui-1.7.2.custom.min.js"></script>
						<link rel="Stylesheet" type="text/css" href="<?php echo $base_url;?>js/jHtmlArea/style/jqueryui/ui-lightness/jquery-ui-1.7.2.custom.css" />
						<script type="text/javascript" src="<?php echo $base_url;?>js/jHtmlArea/scripts/jHtmlArea-0.7.0.js"></script>
						<link rel="Stylesheet" type="text/css" href="<?php echo $base_url;?>js/jHtmlArea/style/jHtmlArea.css" />
						<script type="text/javascript" src="<?php echo $base_url;?>js/jHtmlArea/scripts/jHtmlArea.ColorPickerMenu-0.7.0.js"></script>
						<link rel="Stylesheet" type="text/css" href="<?php echo $base_url;?>js/jHtmlArea/style/jHtmlArea.ColorPickerMenu.css" />
						<style type="text/css">
							/* body { background: #ccc;} */
							div.jHtmlArea .ToolBar ul li a.custom_disk_button 
							{
								background: url('<?php echo $base_url;?>js/jHtmlArea/images/disk.png') no-repeat;
								background-position: 0 0;
							}
							
							div.jHtmlArea { border: solid 1px #ccc; }
						</style>
						<script type="text/javascript">    
						$(function() {
							$("#pro_description").htmlarea({
								// Override/Specify the Toolbar buttons to show
								toolbar: [
								    ["bold", "italic", "underline", "|", "forecolor"],
								    ["increaseFontSize", "decreaseFontSize"],
								    ["p", "h1", "h2", "h3", "h4", "h5", "h6"],
								    ["justifyleft", "justifycenter", "justifyright"]
								]
							});
						});
						</script>
						<div class="form_field_big">
							<b>Description of your listing. The more information the better</b><br />
							<label for="pro_description" id="lblpro_description">Describe your listing</label><br /><br />
							<textarea name="pro_description" class="inputbg" id="pro_description" cols="70" rows="15" style="width:650px;"></textarea>
						</div>
					</div>
						
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>Choose how you want to sell your products</b><br />
							<label for="pro_price" id="lblpro_price" style="margin:10px 0px 0px 0px;">Price</label>
							<label for ="bargin_off" style="width:127px; text-align:center;">Bargain Price Option</label>
							<sup style="float:left; margin:5px 0px 0px 0px;"><a href="javascript:void(0);" id="bargain_price_more_info" onclick="show_more_info(1)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></sup>
							
							<div style="float:left; width:95%;">
								<input type="text" style="width:80px;" name="pro_price" id="pro_price" class="inputbg" onchange="projected_profit()" value="$"   onFocus="clearIndicator(this,'$')" onClick="clearIndicator(this,'$')" onblur="format_value('pro_price')"  />
								
								
								
								<img src="images/on_big_03.png" align="absmiddle" id="bargin_on" alt="ON" onclick="toggle_bargain_img(1)"  style="margin:0px 0px 0px 60px;" /> &nbsp;OR&nbsp;
								<img src="images/off_small_07.png" align="absmiddle" id="bargin_off" style="cursor:pointer;" onclick="toggle_bargain_img(0)" alt="OFF" />
								<input type="hidden" name="bargain_price_option" id="bargain_price_option" value="1" />
								<script>
									function toggle_bargain_img(a)
									{
										if(a==0)
										{
											$('#bargin_on').attr({src: "images/on_small_07.png", title: "ON", alt: "ON"});
											$('#bargin_on').css('cursor','pointer');
											$('#bargin_off').attr({src: "images/off_big_03.png", title: "OFF", alt: "OFF"});
											$('#bargin_off').css('cursor','default');
										}
										else
										{
											$('#bargin_on').attr({src: "images/on_big_03.png", title: "ON", alt: "ON"});
											$('#bargin_on').css('cursor','default');
											$('#bargin_off').attr({src: "images/off_small_07.png", title: "OFF", alt: "OFF"});
											$('#bargin_off').css('cursor','pointer');
										}
										$('#bargain_price_option').val(a);
									}
								</script>
								<span style="float:left; color:red; width:100px; display:none;" id="digit_err1">Digits Only</span>
							</div>
						</div>
						
						<div class="form_field_big">
							<label for="pro_courior" id="lblpro_courior">Shipping Service</label><br /><br />
							<select class="inputbg" name="pro_courior" id="pro_courior" style="width:150px;">										
								<option value=''>..Select..</option>
								<?php 		
								$qry="SELECT * FROM tbl_shipping_service";
								$res=mysql_query($qry);
								if(mysql_num_rows($res) > 0)
								{
								?>
													
								<?php				
									while($row = mysql_fetch_assoc($res))
									{
									?>				
										<option value="<?php echo $row['shipping_id'] ?>"><?php echo $row['shipping_name'];?></option>
									<?php		
									}
									?>
							<?php
								}						
								?>																	
							</select>
						</div>
						
						 
						
						<div class="form_field_big">
							<label for="pro_ship" id="lblpro_ship">Shipping cost</label><br /><br />
							
							<input type="text" style="width:80px; float:left;" class="inputbg" name="pro_ship" id="pro_ship"  onchange="projected_profit()" value="$"  onFocus="clearIndicator(this,'$')" onClick="clearIndicator(this,'$')"  onblur="format_value('pro_ship')"  />
							
							<div style="float:left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
							<input type="checkbox" class="inputbg" style="width: 15px; float:left;" name="ship_status" id="ship_status"  onclick="funcheckShip()" />
							<label for="ship_status" style="width:100px;">Free Shipping</label>
							<input type="checkbox" class="inputbg" style="width: 15px; float:left;" name="localPickup" id="localPickup" value="1" />
							<label for="localPickup" style="width:130px;">Free Local Pickup</label>
							<label style="width:150px;"><a href="javascript:void(0);" id="local_pickup_more_info" onclick="show_more_info(2)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></label>
							<span style="float:left; color:red; width:100px; display:none;" id="digit_err2">Digits Only</span>
						</div>
						
						<?php /* 
						<div class="form_field_big">
							<label for="remarks">Shipping Time</label><br /><br />
							<select name="pro_shipping" id="pro_shipping" style="width:84px;">										
								<option value=''>..Select..</option>
								<?php 		
								$qry="SELECT * FROM tbl_handling_time";
								$res=mysql_query($qry);
									if(mysql_num_rows($res) > 0)
									{
									?>
														
									<?php				
										while($row = mysql_fetch_assoc($res))
										{
										?>				
											<option value="<?php echo $row['handling_time_id'] ?>"><?php echo $row['handling_time_name'];?></option>
										<?php		
										}
										?>
								<?php
									}						
								?>																	
							</select>
						</div>
						      */ ?>
						
						<!--<div class="form_field_big">
							<label for="pro_commission" style="width:200px; margin:10px 0px 0px 0px;">Commission <a href="javascript:void(0);" id="commission_more_info" onclick="show_more_info(3)">more info <img  src="images/small_yellow_star.jpg" style="border:0px" /></a></label>
							<label for ="bargin_c_off" style="width:163px; text-align:center; margin:10px 0px 0px 0px;">Bargain Commission Option</label>
							<label style="width:150px; text-align:left; margin:10px 0px 0px 0px;"><a href="javascript:void(0);" id="bargain_commission_more_info" onclick="show_more_info(4)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></label>
							<div style="float:left; width:95%;">
								<input type="text" style="width:80px; " name="pro_commission" id="pro_commission" class="inputbg" onchange="$('#pc').html(this.value);"  value="$"  onblur="format_value('pro_commission')" onFocus="clearIndicator(this,'$')" onClick="clearIndicator(this,'$')"   /> &nbsp;&nbsp;&nbsp;&nbsp;
								
								
								<img src="images/on_big_03.png" align="absmiddle" id="bargin_c_on" alt="ON" onclick="toggle_bargain_c_img(1)" style="margin:0px 0px 0px 107px;"  /> &nbsp;OR&nbsp;
								<img src="images/off_small_07.png" align="absmiddle" id="bargin_c_off" style="cursor:pointer;" onclick="toggle_bargain_c_img(0)" alt="OFF" />
								<input type="hidden" name ="bargain_commission_option" id="bargain_commission_option" value="1" />
								<script type="text/javascript">
								function toggle_bargain_c_img(a)
								{
									if(a==0)
									{
										$('#bargin_c_on').attr({src: "images/on_small_07.png", title: "ON", alt: "ON"});
										$('#bargin_c_on').css('cursor','pointer');
										$('#bargin_c_off').attr({src: "images/off_big_03.png", title: "OFF", alt: "OFF"});
										$('#bargin_c_off').css('cursor','default');
									}
									else
									{
										$('#bargin_c_on').attr({src: "images/on_big_03.png", title: "ON", alt: "ON"});
										$('#bargin_c_on').css('cursor','default');
										$('#bargin_c_off').attr({src: "images/off_small_07.png", title: "OFF", alt: "OFF"});
										$('#bargin_c_off').css('cursor','pointer');
									}
									$('#bargain_commission_option').val(a);
								}
								</script>
								<span style="float:left; color:red; width:100px; display:none;" id="digit_err3">Digits Only</span>
							</div>
						</div>-->
						
						<div class="form_field_big">
							<label for="pro_quantity" id="lblpro_quantity">Quantity</label><br /><br />
							
							<input type="text" style="width:80px;" name="pro_quantity" id="pro_quantity" class="inputbg" />
							
						</div>
						
						<?php if($userType=='2' || $userType=='4')
						{ 
							if($_GET['by']=='own')
							{
								echo "<input type='hidden' name='sell_by' value='1'>";
								
							}
							else if($_GET['by']=='seller') {
							      echo "<input type='hidden' name='sell_by' value='0'>";
							}
							else
							{
								?>
								<div class="form_field_big">
									<label for="sell_by">Sell by</label><br /><br />
									<div id="sellby-div">
										<label>Seller</label><input type="radio" class="inputbg" name="sell_by" id="sell_by_seller" value="0" checked />					  
										<label>Owner</label><input type="radio" class="inputbg" name="sell_by" id="sell_by_owner" value="1" />
										  
									</div>
								</div>
			   
						<?php	} 
						}
						else {
							echo "<input type='hidden' name='sell_by' value='0'>";
						}
						?>
						
						<div class="form_field_big">
							<label for="pro_condition" id="lblpro_condition">Condition</label><br /><br />
							<select name="pro_condition" id="pro_condition" class="inputbg" style="width:174px;">										
								<option value=''>..Select..</option>
								<option value="New">New</option>
								<option value="New (package open)">New (package open)</option>
								<option value="Manufacturer Refurbished">Manufacturer Refurbished</option>
								<option value="For parts not working">For parts not working</option>
								<option value="Original, Reproduction">Original, Reproduction</option>
								<option value="Seller Refurbished">Seller Refurbished</option>
								<option value="Used">Used</option>																
							</select>
						</div>
						
						<div class="form_field_big">
							<label for="sale_tax"  style="width:260px; vertical-align:top">Sales Tax (if applicable) &nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" id="sales_tax_more_info" onclick="show_more_info(5)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></label><br /><br /><br />
								
									
							<?php 		
							$qry="SELECT * FROM tbl_state where country_id='213'";
							$res=mysql_query($qry);
							if(mysql_num_rows($res) > 0)
							{
								while($row = mysql_fetch_assoc($res))
								{
									$options.='<option value="'.$row['stateid'].'">'.$row['statename'].'</option>';
								}
							}
							?>
							<select name="sale_tax" id="sale_tax" style="width:145px; float:left;"><?php echo $options; ?></select>&nbsp;&nbsp;
							
							<input type="text" name="sales_tax" id="sales_tax" onblur="javascript:return MaskMoney(event);format_value('sales_tax');"  class="inputbg" />
							 %
							
						</div>
						
						<div class="form_field_big">
							<label for="pro_policy" id="lblpro_policy">Return Policy</label><br /><br />
							<select name="pro_policy" id="pro_policy" class="inputbg" style="width:150px;">										
								<option value=''>..Select..</option>
								<option value='Accept Returns'>Accept Returns</option>
								<option value='Don`t Accept Returns'>Don't Accept Returns</option>
							</select><br /><br /><br />
							<textarea name="remarks" class="inputbg" id="remarks" style="height:40px; font-size:12px;"></textarea>
						</div>
						
						
						<div class="form_field_big">
							<label style="width:320px; vertical-align:top" for="amazon_name">Amazon Receiving Funds Account &nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" id="amazon_more_info" onclick="show_more_info(6)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></label><br /><br /><br />
							
							<input type="text" style="width:220px;" name="amazon_name" id="amazon_name" class="inputbg" value="<?php echo $amazonaccnt?>"  />
							&nbsp; Dont have one yet? Sign Up <a target="_blank" href="https://payments.amazon.com/sdui/sdui/index.htm">here</a>
						</div>
						
					</div>
						
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>OPTIONAL - Free gift with purchase. An extra incentive always helps.</b><br />
							<label for="gift_name">Gift Name</label><br /><br />
							
							<input type="text" name="gift_name" id="gift_name" class="inputbg" />
							
						</div>
						
						<div class="form_field_big">
							<label for="gift_description">Free Gift Desciption</label><br /><br />
							<textarea name="gift_description" id="gift_description" class="inputbg" style="height:70px; width:500px; font-size:12px;"></textarea>
						</div>
						
						<div class="form_field_big">
							<label for="remarks">Free Gift Image</label><br /><br />
							<?php /*
							<div style="float:left; width:50px;">&nbsp;</div><!--This div is to give some blank space before button 1 starts-->
							<div style="float:left; margin-bottom:-10px; margin-right:10px;">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 1 <img src="images/success.gif" align="absmiddle" /></label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
							*/
							?>
							<label for="gift_image">Gift Image</label><br /><br /><br />
							<input type="file" class="inputbg" name="gift_image" id="gift_image" style="float:left;" />
						</div>
					</div>
					
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>Fees and Profit Breakdown</b><br />
							<div style="float:left; width:250px; margin:10px 0px 10px 50px;">
								<div style="float:left; width:150px; text-align:left;">Product Price</div>
								<div style="float:left; width:100px; text-align:right;">$ <span id="pp">0.00</span></div>
								<div style="float:left; width:150px; text-align:left;">Listing Fee</div>
								<div style="float:left; width:100px; text-align:right;">$ <span id="lf">0.00</span></div>
								<div style="float:left; width:150px; text-align:left;">Images Fee</div>
								<div style="float:left; width:100px; text-align:right;">$ <span id="if">0.00</span></div>
								<div style="float:left; width:150px; text-align:left;">Commission Offered</div>
								<div style="float:left; width:100px; text-align:right;">$ <span id="pc">0.00</span></div>
								<div style="float:left; width:200px;">&nbsp;</div>
								<div style="float:left; width:150px; text-align:left;">Swapen Charges</div>
								<div style="float:left; width:100px; text-align:right;"><span id="sc">3</span>%</div>
								<div style="float:left; width:250px;"><hr /></div>
								<div style="float:left; width:150px; text-align:left; color:#b5b5b5;">Projected Profit</div>
								<div style="float:left; width:100px; text-align:right; color:red;"><span id="prp"><b>$0.00</b></span></div>
							</div>
						</div>
						
					</div>
					
					<div class="form_field_big">
						<div style="margin-left: 200px;" class="checkbox"><input type="checkbox" name="i_agree" id="i_agree" /></div> I agree that:
						<span style="float: right;"><a href="javascript:void(0);" onclick="show_preview()">Preview</a></span>
						<div style="float: left; width: 95%; margin-top: 20px;">
							<ul style="float: left; margin-left: 200px;">
							    <li>I accept the User Agreements and Privacy Policy</li>
							    <li>I may recieve communications from swapen</li>
							    <li>I am atleast 18 years old</li>
							</ul>
						</div>
						<div id="errMsg" style="float:left; width:100%;" align="center"></div>
					</div>
					
					<div align="center" class="form_field_big">
						<input type="hidden" name="keyword" id="keyword" />
						<input type="submit" name="submit" id="submit" value="Submit Listing" class="sbmt_btn" />
					</div>
						
						
				</div>
				<div class="fullbox2_bot"></div>
			</div>
		</form>
		</td>
		</tr>
  
  
  
		<?php
			}//else of if($rowChkItems[0]>=100 && $_GET['by']=='seller') 
		}//else of if(empty($userInfo['tokenID']))
}
else { ?>
	<tr>
		<td>
		
			<div class="whitebox950">
				<div class="fullbox2_top"></div>
				<div class="fullbox2_repeat">
					<div class="blue_box_big" align="center">
						<img src="<?php echo $base_url;?>images/create_ur_prod_list.png" /><br />
						<font style="color:#B7B5B5;">Quickly and Easily post all your products here. </font>
						<br />&nbsp;
						<span style="float:left; text-align:right; width:97%;"><a href="javascript:void(0);">help</a></span>
					
					</div>
					
					<div class="blue_box_big">
						<div class="bluebar_left_big"></div>
						<div class="bluebar_center_big"><span>Choose Category</span></div>
						<div class="bluebar_right_big"></div>
					</div>
					
					<div class="inner_round_box">
						<div class="form_field_big">
							<label for="pro_subcategory" id="lblpro_subcategory">Category</label><br /><br />
							<select class="inputbg" name="pro_subcategory" id="pro_subcategory" onChange="getSubSubCat(this.value,'sub-sub-category');">
							<option value="">..Select Category..</option>
							<?php				
							$sql_shocat="SELECT * FROM tbl_category where parent_id='1'";
							$rst_shocat=mysql_query($sql_shocat);
							while($row_shocat=mysql_fetch_array($rst_shocat)) {
								 $cat_id=$row_shocat['category_id'];
								 $cat_name=$row_shocat['category_name'];							 
								 echo "<option value='$cat_id'>$cat_name</option>";
							}
							?>
							</select>
							<span id="loader-div1"></span>
						</div>
						
						<div class="form_field_big" id="sub-sub-category">
							<label for="pro_sub_subcategory" id="lblpro_sub_subcategory">Sub Category</label><br /><br />
							<select class="inputbg" name="pro_sub_subcategory" id="pro_sub_subcategory">
								<option value="">..Select subcategory..</option>
							</select><br>
						</div>
					
					</div>
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>Buyers will locate your item better with a good descriptive listing name</b>
							<br />
							<label for="pro_name" id="lblpro_name">Listing Name</label><br /><br />
							<span>
								
								<input type="text" style="width: 400px;" class="inputbg" id="pro_name" name="pro_name" />
								
							</span>
							<font style="font-size:10px; color:#636060;">
								<b>Re-called items:</b> It is solely your responsibility to make sure your item has not be recalled. If you are unsure please check <a href="http://www.recalls.gov" target="_blank">here</a>
							</font>
						</div>
					</div>
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>Add free images to make your listing stand out</b>
							<br /><br />
							<?php
							/*
							<div style="float:left; width:50px;">&nbsp;</div><!--This div is to give some blank space before button 1 starts-->
							
							<div style="float:left; margin-bottom:-10px; margin-right:10px;">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 1 <img src="images/success.gif" align="absmiddle" /></label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
							<div style="float:left; margin-bottom:-10px; margin-right:10px;">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 2</label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
							<div style="float:left; margin-bottom:-10px; margin-right:10px;">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 3</label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
							<div style="float:left; margin-bottom:-10px; margin-right:10px;">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 4</label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
							<div style="float:left; margin-bottom:-10px; margin-right:10px;">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 5</label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
							*/
							?>
							<label for="pro_image1">Product Image 1</label><br /><br /><br />
							<input class="inputbg" type="file" name="pro_image1" id="pro_image1" style="float:left;" />
						</div>
						<div class="form_field_big">
							<label for="pro_image2">Product Image 2</label><br /><br /><br />
							<input class="inputbg" type="file" name="pro_image2" id="pro_image2" style="float:left;" />
						</div>
						<div class="form_field_big">
							<label for="pro_image3">Product Image 3</label><br /><br />
							<input class="inputbg" type="file" name="pro_image3" id="pro_image3" style="float:left;" />
							
						</div>
						<div class="form_field_big">
							<label for="pro_image4">Product Image 4</label><br /><br /><br />
							<input class="inputbg" type="file" name="pro_image4" id="pro_image4" style="float:left;" />
						</div>
						<div class="form_field_big">
							<label for="pro_image5">Product Image 5</label><br /><br /><br />
							<input class="inputbg" type="file" name="pro_image5" id="pro_image5" style="float:left;" />
						</div>
					</div>
					
					<div class="inner_round_box">
						<script type="text/javascript" src="<?php echo $base_url;?>js/jHtmlArea/scripts/jquery-ui-1.7.2.custom.min.js"></script>
						<link rel="Stylesheet" type="text/css" href="<?php echo $base_url;?>js/jHtmlArea/style/jqueryui/ui-lightness/jquery-ui-1.7.2.custom.css" />
						<script type="text/javascript" src="<?php echo $base_url;?>js/jHtmlArea/scripts/jHtmlArea-0.7.0.js"></script>
						<link rel="Stylesheet" type="text/css" href="<?php echo $base_url;?>js/jHtmlArea/style/jHtmlArea.css" />
						<script type="text/javascript" src="<?php echo $base_url;?>js/jHtmlArea/scripts/jHtmlArea.ColorPickerMenu-0.7.0.js"></script>
						<link rel="Stylesheet" type="text/css" href="<?php echo $base_url;?>js/jHtmlArea/style/jHtmlArea.ColorPickerMenu.css" />
						<style type="text/css">
							/* body { background: #ccc;} */
							div.jHtmlArea .ToolBar ul li a.custom_disk_button 
							{
								background: url('<?php echo $base_url;?>js/jHtmlArea/images/disk.png') no-repeat;
								background-position: 0 0;
							}
							
							div.jHtmlArea { border: solid 1px #ccc; }
						</style>
						<script type="text/javascript">    
						$(function() {
							$("#pro_description").htmlarea({
								// Override/Specify the Toolbar buttons to show
								toolbar: [
								    ["bold", "italic", "underline", "|", "forecolor"],
								    ["increaseFontSize", "decreaseFontSize"],
								    ["p", "h1", "h2", "h3", "h4", "h5", "h6"],
								    ["justifyleft", "justifycenter", "justifyright"]
								]
							});
						});
						</script>
						<div class="form_field_big">
							<b>Description of your listing. The more information the better</b><br />
							<label for="pro_description" id="lblpro_description">Describe your listing</label><br /><br />
							<textarea class="inputbg" name="pro_description" id="pro_description" cols="70" rows="15" style="width:650px;"></textarea>
						</div>
					</div>
						
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>Choose how you want to sell your products</b><br />
							<label for="pro_price" id="lblpro_price" style="margin:10px 0px 0px 0px;">Price</label>
							<label for ="bargin_off" style="width:127px; text-align:center;">Bargain Price Option</label>
							<sup style="float:left; margin:5px 0px 0px 0px;"><a href="javascript:void(0);" id="bargain_price_more_info" onclick="show_more_info(1)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></sup>
							
							<div style="float:left; width:95%;">
								<input type="text" style="width:80px;" name="pro_price" id="pro_price" class="inputbg" onchange="projected_profit()" value="$"   onFocus="clearIndicator(this,'$')" onClick="clearIndicator(this,'$')" onblur="format_value('pro_price')"  />
								
								
								<img src="images/on_big_03.png" align="absmiddle" id="bargin_on" alt="ON" onclick="toggle_bargain_img(1)"  style="margin:0px 0px 0px 60px;" /> &nbsp;OR&nbsp;
								<img src="images/off_small_07.png" align="absmiddle" id="bargin_off" style="cursor:pointer;" onclick="toggle_bargain_img(0)" alt="OFF" />
								<input type="hidden" name="bargain_price_option" id="bargain_price_option" value="1" />
								<script>
									function toggle_bargain_img(a)
									{
										if(a==0)
										{
											$('#bargin_on').attr({src: "images/on_small_07.png", title: "ON", alt: "ON"});
											$('#bargin_on').css('cursor','pointer');
											$('#bargin_off').attr({src: "images/off_big_03.png", title: "OFF", alt: "OFF"});
											$('#bargin_off').css('cursor','default');
										}
										else
										{
											$('#bargin_on').attr({src: "images/on_big_03.png", title: "ON", alt: "ON"});
											$('#bargin_on').css('cursor','default');
											$('#bargin_off').attr({src: "images/off_small_07.png", title: "OFF", alt: "OFF"});
											$('#bargin_off').css('cursor','pointer');
										}
										$('#bargain_price_option').val(a);
									}
								</script>
								<span style="float:left; color:red; width:100px; display:none;" id="digit_err1">Digits Only</span>
							</div>
						</div>
						
						<div class="form_field_big">
							<label for="pro_courior" id="lblpro_courior">Shipping Service</label><br /><br />
							<select name="pro_courior" id="pro_courior" class="inputbg" style="width:150px;">										
								<option value=''>..Select..</option>
								<?php 		
								$qry="SELECT * FROM tbl_shipping_service";
								$res=mysql_query($qry);
								if(mysql_num_rows($res) > 0)
								{
								?>
													
								<?php				
									while($row = mysql_fetch_assoc($res))
									{
									?>				
										<option value="<?php echo $row['shipping_id'] ?>"><?php echo $row['shipping_name'];?></option>
									<?php		
									}
									?>
							<?php
								}						
								?>																	
							</select>
						</div>
						
						 
						
						<div class="form_field_big">
							<label for="pro_ship" id="lblpro_ship">Shipping cost</label><br /><br />
							
							<input type="text" style="width:80px; float:left;" class="inputbg" name="pro_ship" id="pro_ship"  onchange="projected_profit()" value="$"  onFocus="clearIndicator(this,'$')" onClick="clearIndicator(this,'$')"  onblur="format_value('pro_ship')"  />
							
							<div style="float:left;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</div>
							<input class="inputbg" type="checkbox" style="width: 15px; float:left;" name="ship_status" id="ship_status"  onclick="funcheckShip()" />
							<label for="ship_status" style="width:100px;">Free Shipping</label>
							<input class="inputbg" type="checkbox" style="width: 15px; float:left;" name="localPickup" id="localPickup" value="1" />
							<label for="localPickup" style="width:130px;">Free Local Pickup</label>
							<label style="width:150px;"><a href="javascript:void(0);" id="local_pickup_more_info" onclick="show_more_info(2)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></label>
							<span style="float:left; color:red; width:100px; display:none;" id="digit_err2">Digits Only</span>
						</div>
			
						
						<?php /* 
						<div class="form_field_big">
							<label for="remarks">Shipping Time</label><br /><br />
							<select name="pro_shipping" id="pro_shipping" style="width:84px;">										
								<option value=''>..Select..</option>
								<?php 		
								$qry="SELECT * FROM tbl_handling_time";
								$res=mysql_query($qry);
									if(mysql_num_rows($res) > 0)
									{
									?>
														
									<?php				
										while($row = mysql_fetch_assoc($res))
										{
										?>				
											<option value="<?php echo $row['handling_time_id'] ?>"><?php echo $row['handling_time_name'];?></option>
										<?php		
										}
										?>
								<?php
									}						
								?>																	
							</select>
						</div>
						      */ ?>
								
						<!--<div class="form_field_big">
							<label for="pro_commission" style="width:200px; margin:10px 0px 0px 0px;">Commission <a href="javascript:void(0);" id="commission_more_info" onclick="show_more_info(3)">more info <img  src="images/small_yellow_star.jpg" style="border:0px" /></a></label>
							<label for ="bargin_c_off" style="width:165px; text-align:center; margin:10px 0px 0px 0px;">Bargain Commission Option</label>
							<label style="width:150px; text-align:left; margin:10px 0px 0px 0px;"><a href="javascript:void(0);" id="bargain_commission_more_info" onclick="show_more_info(4)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></label>
							<div style="float:left; width:95%;">
								<input type="text" style="width:80px; " name="pro_commission" id="pro_commission" class="inputbg" onchange="$('#pc').html(this.value);"  value="$"  onblur="format_value('pro_commission')" onFocus="clearIndicator(this,'$')" onClick="clearIndicator(this,'$')"   /> &nbsp;&nbsp;&nbsp;&nbsp;
								

								

								<img src="images/on_big_03.png" align="absmiddle" id="bargin_c_on" alt="ON" onclick="toggle_bargain_c_img(1);" style="margin:0px 0px 0px 107px;" /> &nbsp;OR&nbsp;
								<img src="images/off_small_07.png" align="absmiddle" id="bargin_c_off" style="cursor:pointer;" onclick="toggle_bargain_c_img(0)" alt="OFF" />
								<input type="hidden" name ="bargain_commission_option" id="bargain_commission_option" value="1" />
								<script type="text/javascript">
								function toggle_bargain_c_img(a)
								{
									if(a==0)
									{
										$('#bargin_c_on').attr({src: "images/on_small_07.png", title: "ON", alt: "ON"});
										$('#bargin_c_on').css('cursor','pointer');
										$('#bargin_c_off').attr({src: "images/off_big_03.png", title: "OFF", alt: "OFF"});
										$('#bargin_c_off').css('cursor','default');
									}
									else
									{
										$('#bargin_c_on').attr({src: "images/on_big_03.png", title: "ON", alt: "ON"});
										$('#bargin_c_on').css('cursor','default');
										$('#bargin_c_off').attr({src: "images/off_small_07.png", title: "OFF", alt: "OFF"});
										$('#bargin_c_off').css('cursor','pointer');
									}
									$('#bargain_commission_option').val(a);
								}
								</script>
								<span style="float:left; color:red; width:100px; display:none;" id="digit_err3">Digits Only</span>
							</div>
						</div>-->
						
						<div class="form_field_big">
							<label for="pro_quantity" id="lblpro_quantity">Quantity</label><br /><br />
							
							<input type="text" style="width:80px;" name="pro_quantity" id="pro_quantity" class="inputbg" onblur="isInteger(this.value);" />
							
						</div>
						
						<?php if($userType=='2' || $userType=='4')
						{ 
							if($_GET['by']=='own')
							{
								echo "<input type='hidden' name='sell_by' value='1'>";
								?>
								
								<?php
							}
							else if($_GET['by']=='seller') {
							      echo "<input type='hidden' name='sell_by' value='0'>";
							}
							else
							{
								?>
								<div class="form_field_big">
									<label for="sell_by">Sell by</label><br /><br />
									<div id="sellby-div">
										<label>Seller</label><input class="inputbg" type="radio" name="sell_by" id="sell_by_seller" value="0" checked />					  
										<label>Owner</label><input class="inputbg" type="radio" name="sell_by" id="sell_by_owner" value="1" />
										  
									</div>
								</div>
			   
						<?php	} 
						}
						else {
							echo "<input type='hidden' name='sell_by' value='0'>";
						}
						?>
						
						<div class="form_field_big">
							<label for="pro_condition" id="lblpro_condition">Condition</label><br /><br />
							<select class="inputbg" name="pro_condition" id="pro_condition" style="width:174px;">										
								<option value=''>..Select..</option>
								<option value="New">New</option>
								<option value="New (package open)">New (package open)</option>
								<option value="Manufacturer Refurbished">Manufacturer Refurbished</option>
								<option value="For parts not working">For parts not working</option>
								<option value="Original, Reproduction">Original, Reproduction</option>
								<option value="Seller Refurbished">Seller Refurbished</option>
								<option value="Used">Used</option>																
							</select>
						</div>
						
						<div class="form_field_big">			
							<label for="sale_tax"  style="width:260px; vertical-align:top">Sales Tax (if applicable) &nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" id="sales_tax_more_info" onclick="show_more_info(5)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></label><br /><br /><br />
									
							<?php 		
							$qry="SELECT * FROM tbl_state where country_id='213'";
							$res=mysql_query($qry);
							if(mysql_num_rows($res) > 0)
							{
								while($row = mysql_fetch_assoc($res))
								{
									$options.='<option value="'.$row['stateid'].'">'.$row['statename'].'</option>';
								}
							}
							?>
							<select class="inputbg" name="state" id="state" style="width:145px; float:left;"><?php echo $options; ?></select>&nbsp;&nbsp;
							
							<input type="text" name="sales_tax" id="sales_tax" onblur="format_value('sales_tax')"  class="inputbg" />
							 %
							
						</div>
						
						<div class="form_field_big">
							<label for="pro_policy" id="lblpro_policy">Return Policy</label><br /><br />
							<select class="inputbg" name="pro_policy" id="pro_policy" style="width:150px;">										
								<option value=''>..Select..</option>
								<option value='Accept Returns'>Accept Returns</option>
								<option value='Don`t Accept Returns'>Don't Accept Returns</option>
							</select><br /><br /><br />
							<textarea class="inputbg" name="remarks" id="remarks" style="height:40px; font-size:12px;"></textarea>
						</div>
						
					
						
						<div class="form_field_big">
							
							<label style="width:320px; vertical-align:top" for="amazon_name">Amazon Receiving Funds Account &nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" id="amazon_more_info" onclick="show_more_info(6)">more info <img align="absmiddle" src="images/small_yellow_star.jpg" style="border:0px" /></a></label><br /><br /><br />
							
							<input type="text" style="width:220px; color:#b5b5b5;" name="amazon_name" id="amazon_name" class="inputbg" value="Amazon Business Account Name"/>
							&nbsp; Dont have one yet? Sign Up <a target="_blank" href="https://www.amazon.com/ap/signin?_encoding=UTF8&openid.assoc_handle=usflex&openid.return_to=https%3A%2F%2Fwww.amazon.com%2Fgp%2Fyourstore%3Fie%3DUTF8%26ref_%3Dpd_irl_gw_r&openid.mode=checkid_setup&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.claimed_id=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select&openid.pape.max_auth_age=0&openid.ns.pape=http%3A%2F%2Fspecs.openid.net%2Fextensions%2Fpape%2F1.0&openid.identity=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0%2Fidentifier_select">here</a>
						</div>
						
					</div>
						
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>OPTIONAL - Free gift with purchase. An extra incentive always helps.</b><br />
							<label for="gift_name">Gift Name</label><br /><br />
							
							<input type="text" name="gift_name" id="gift_name" class="inputbg" />
							
						</div>
						
						<div class="form_field_big">
							<label for="gift_description">Free Gift Desciption</label><br /><br />
							<textarea class="inputbg" name="gift_description" id="gift_description" style="height:70px; width:500px;  font-size:12px;"></textarea>
						</div>
						
						<div class="form_field_big">
							<label for="remarks">Free Gift Image</label><br /><br />
							<?php /*
							<div style="float:left; width:50px;">&nbsp;</div><!--This div is to give some blank space before button 1 starts-->
							<div style="float:left; margin-bottom:-10px; margin-right:10px;">
								<div class="btn_uplimg_left"></div>
								<div class="btn_uplimg_repeat">
									<label style="width:100px; text-align:center; font-weight:bold; margin-top:5px;">Image 1 <img src="images/success.gif" align="absmiddle" /></label>
								</div>
								<div class="btn_uplimg_right"></div>
							</div>
							*/
							?>
							<label for="gift_image">Gift Image</label><br /><br /><br />
							<input type="file" name="gift_image" id="gift_image" style="float:left;" />
						</div>
					</div>
					
					<div class="inner_round_box">
						<div class="form_field_big">
							<b>Fees and Profit Breakdown</b><br />
							<div style="float:left; width:250px; margin:10px 0px 10px 50px;">
								<div style="float:left; width:150px; text-align:left;">Product Price</div>
								<div style="float:left; width:100px; text-align:right;">$ <span id="pp">0.00</span></div>
								<div style="float:left; width:150px; text-align:left;">Listing Fee</div>
								<div style="float:left; width:100px; text-align:right;">$ <span id="lf">0.00</span></div>
								<div style="float:left; width:150px; text-align:left;">Images Fee</div>
								<div style="float:left; width:100px; text-align:right;">$ <span id="if">0.00</span></div>
								<div style="float:left; width:150px; text-align:left;">Commission Offered</div>
								<div style="float:left; width:100px; text-align:right;">$ <span id="pc">0.00</span></div>
								<div style="float:left; width:200px;">&nbsp;</div>
								<div style="float:left; width:150px; text-align:left;">Swapen Charges</div>
								<div style="float:left; width:100px; text-align:right;"><span id="sc">3</span>%</div>
								<div style="float:left; width:250px;"><hr /></div>
								<div style="float:left; width:150px; text-align:left; color:#b5b5b5;">Projected Profit</div>
								<div style="float:left; width:100px; text-align:right; color:red;"><span id="prp"><b>$0.00</b></span></div>
							</div>
						</div>
						
					</div>
					
					<div class="form_field_big">
						<div style="margin-left: 200px;" class="checkbox"><input type="checkbox" name="i_agree" id="i_agree" /></div> I agree that:
						<span style="float: right;"><a href="javascript:void(0);" onclick="show_preview()">Preview</a></span>
						<div style="float: left; width: 95%; margin-top: 20px;">
							<ul style="float: left; margin-left: 200px;">
							    <li>I accept the User Agreements and Privacy Policy</li>
							    <li>I may recieve communications from swapen</li>
							    <li>I am atleast 18 years old</li>
							</ul>
						</div>
						<div id="errMsg" style="float:left; width:100%;" align="center"></div>
					</div>
					
					<div align="center" class="form_field_big">
						<input type="hidden" name="keyword" id="keyword" />
						<input type="submit" name="submit" id="submitbutton" value="Submit Listing" class="sbmt_btn" onclick="show_login()" />
					</div>
						
						
				</div>
				<div class="fullbox2_bot"></div>
			</div>
		
		</td>
		</tr>

<?php
}
?>

</table>

</div>
<div id="preview_overlay"></div>
<div style="display: none; width: 400px; font-weight:bold; padding:10px; background-color:#cccccc; " class="user_popup" id="more_info">
	<span style="float:left; width:100%; text-align:right; margin-bottom:5px;"><label style="cursor:pointer;" onclick="$('#more_info').fadeOut('slow');">x</label></span>
	<span style="float:left; width:100%; margin-bottom:10px;" id="desc_info_n"></span>
</div>


<div class="user_popup" id="login_box" style="z-index:10000;">
  <div class="full_div">
  <span style="float: right; padding: 5px; font-weight: bold; cursor: pointer;" onclick="$('#login_box').fadeOut('slow');">x</span>
  </div>

  <div class="full_div" align="center">
    
    <input type="text" name="username" value="Username" id="username" class="inputbg" style="width:130px;" onBlur="putIndicator(this,'Username')" onFocus="clearIndicator(this,'Username')" onClick="clearIndicator(this,'Username')" />
    
  </div>
  <div class="full_div" align="center">
    
    <input type="password" name="password" value="Password" id="password" class="inputbg" style="width:130px;"  onBlur="putIndicator(this,'Password')" onFocus="clearIndicator(this,'Password')" onClick="clearIndicator(this,'Password')" />
    
  </div>
  <div class="fulldiv" align="center" >
     <input type="button" name="login" value="Sign In " id="login" class="button" onclick="validateLogin()" />
     <span style="font-weight:normal;">If you are not a member yet please <a href="<?php echo $base_url;?>index.php?signup">register</a> first.</span>
     <span style="color:red;" id="login_error"></span>
   </div>
  
</div>

<script language="javascript" type="text/javascript">
function onlyint(event,a) {
	
	var charCode = event.keyCode || event.which;
	if(event.shiftKey && charCode == 9)
	{return true}
	else  if (event.shiftKey)
	{	$('#digit_err'+a).show().fadeOut("slow"); return false;	}
	else if  (((event.keyCode == 46) || (event.keyCode >= 48 && event.keyCode <= 57) || (event.keyCode >= 96 && event.keyCode <= 105) || (event.keyCode == 8) || (event.keyCode == 9)) )
	{ return true; } else { $('#digit_err'+a).show().fadeOut("slow"); return false; }
}


function projected_profit()
{
	var pro_price 	= $('#pro_price').val();
	
	var pro_ship = $('#pro_ship').val();
	var pro_comission = $('#pro_commission').val();
	
	if(pro_price=='$')
		pro_price=0.00;
	else
	{
		//alert(pro_price);
		var i 		= pro_price.indexOf('$');
		if(i!=-1)
		{
			var temp1	= pro_price.split('$');
			pro_price	= temp1[1];
		}
		
	}
	
	if(pro_ship=='$' || pro_ship=='Free')
		pro_ship=0.00;
	else
	{
		var j 		= pro_ship.indexOf('$');
		if(j!=-1)
		{
			var temp2	= pro_ship.split('$');
			pro_ship	= temp2[1];
		}
	}
	
	if(pro_comission=='$')
		pro_comission=0.00;
	else
	{
		var k 		= pro_comission.indexOf('$');
		if(k!=-1)
		{
			var temp3	= pro_comission.split('$');
			pro_comission	= temp3[1];
		}
	}
	
	
	
		
	var product_price = parseFloat(pro_price) + parseFloat(pro_ship);
	
	
	if(pro_ship=='$' || pro_ship=='Free')
	{
		if(pro_price!='$') {
			$('#pp').html(parseFloat(pro_price).toFixed(2));
			pro_ship = 0.00;
		}
	}
	else {
		$('#pp').html(parseFloat(product_price).toFixed(2));
		
	}
	$('#pc').html(pro_comission);
	var percnAmt = parseFloat(product_price)*0.03;
	var projectedAmt = parseFloat(product_price) - parseFloat(percnAmt);
	
	
	
	$('#prp').html('<b>$'+projectedAmt.toFixed(2)+'</b>');
}



function validateForm()
{
	var flag=0;
	if($('#pro_subcategory').val()=='')
	{
		flag=flag+1;
		$('#lblpro_subcategory').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_subcategory').css({'font-weight':'bold','color':'#666666'});
	}
	
	if($('#pro_sub_subcategory').val()=='')
	{
		flag=flag+1;
		$('#lblpro_sub_subcategory').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_sub_subcategory').css({'font-weight':'bold','color':'#666666'});
	}
	
	if($('#pro_name').val()=='')
	{
		flag=flag+1;
		$('#lblpro_name').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_name').css({'font-weight':'bold','color':'#666666'});
	}
	
	var pro_description = $("#pro_description").htmlarea("toHtmlString");
	if(pro_description=='')
	{
		flag=flag+1;
		$('#lblpro_description').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_description').css({'font-weight':'bold','color':'#666666'});
	}
	
	if($('#pro_price').val()=='')
	{
		flag=flag+1;
		$('#lblpro_price').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_price').css({'font-weight':'bold','color':'#666666'});
	}
	
	 
	if($('#pro_quantity').val()=='' || !Number($('#pro_quantity').val()))
	{
		flag=flag+1;
		$('#lblpro_quantity').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_quantity').css({'font-weight':'bold','color':'#666666'});
	}
	
	if($('#pro_courior').val()=='')
	{
		flag=flag+1;
		$('#lblpro_courior').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_courior').css({'font-weight':'bold','color':'#666666'});
	}
	if($('#pro_condition').val()=='')
	{
		flag=flag+1;
		$('#lblpro_condition').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_condition').css({'font-weight':'bold','color':'#666666'});
	}
	if($('#pro_policy').val()=='')
	{
		flag=flag+1;
		$('#lblpro_policy').css({'font-weight':'bold','color':'#FF0000'});
	}
	else {
		$('#lblpro_policy').css({'font-weight':'bold','color':'#666666'});
	}
	
	if($("#i_agree").is(":checked")==false)
	{
		flag=flag+1;
		alert('You have to agree our conditions before submiting your data.');
	}
	
	if(flag>0)
	{
		$('#errMsg').html("<font color='#FF0000'><b>We need some additional information from you. Enter valid information in red color highlighted fields and try again.</b></font>");
		return false;
	}
	else
	{
		$('#errMsg').html('');
		return true;
	}
}

function MaskMoney(evt) 
    {
	
    if (!(evt.keyCode == 46 || (evt.keyCode >= 48 && evt.keyCode <= 57))) return false;
    var parts = evt.srcElement.value.split('.');
    if (parts.length > 2) return false;
    if (evt.keyCode == 46) return (parts.length == 1);
    if (parts[0].length >= 14) return false;
    if (parts.length == 2 && parts[1].length >= 2) return false;
    }

function show_login() {
	
	var ntop = (( $(window).height() - $('#submitbutton').height()) / 2+$(window).scrollTop()) - 100;
	var nleft = ( $(window).width() - $('#submitbutton').width()) / 2+$(window).scrollLeft();
	$('#login_box').css({'left': nleft, 'top':ntop});
	$('#login_box').fadeIn('slow');
	//$('#preview_overlay').show();
}
function validateLogin()
{
 // alert('hi');
  var username = $('#username').val();
  var password = $('#password').val();
  $('#login_error').html('');
  if(username=='' || password=='')
  {
    alert('Please enter username and password');
  }
  else
  {
    //alert('hi');
    var url = "<?php echo $base_url;?>ajax_signin.php";
    $.post(url,
    { 'username': username, 'password':password},
    function(data)
    {
      //alert(data);
      if(data=='Your account is on hold, please contact us for more information')
	$('#login_error').html(data);
      else if(data=='Your Account has been placed on the inactive list, please contact Swapen Support')
	$('#login_error').html(data);
      else if(data=='Invalid user name and password.')
	$('#login_error').html(data);
      else if(data=='')
	window.location='index.php';
      else
	window.location='index.php?'+data;
	    
    },
    'html'
    );
  }
}

//function for saving in draft table
function save_to_draft()
{
	   var pro_name = $('#pro_name').val();
	   if(pro_name=="")
	   {
		alert("Please enter atleast listing name to save in draft.");
	   }
	   else
	   {
		var pro_subcategory = $('#pro_subcategory').val();
		var pro_sub_subcategory = $('#pro_sub_subcategory').val();
		var pro_name = $('#pro_name').val();
		var pro_description = $("#pro_description").htmlarea("toHtmlString");


		//var pro_description = $('#pro_description').html();
		var pro_price = $('#pro_price').val();
		var bargain_price_option = $('#bargain_price_option').val();
		var pro_courior = $('#pro_courior').val();
		
		if($("#ship_status").is(":checked")==false) 
		var ship_status = 0;
		else
		var ship_status = 1;
		var pro_ship = $('#pro_ship').val();
		if($("#localPickup").is(":checked")==false) 
		var localPickup = 0;
		else
		var localPickup = 1;
		var pro_commission = $('#pro_commission').val();
		var bargain_commission_option = $('#bargain_commission_option').val();
		var pro_quantity = $('#pro_quantity').val();
		var pro_condition = $('#pro_condition').val();
		var sales_tax = $('#sales_tax').val();
		var pro_policy = $('#pro_policy').val();
		var remarks = $('#remarks').val();
		var amazon_name = $('#amazon_name').val();
		var gift_name = $('#gift_name').val();
		var gift_description = $('#gift_description').val();
		var page = 'sell_product';
		var user_id = '<?php echo $_SESSION['user_id_sess'];?>';
		
		var url = "<?php echo $base_url;?>ajax_drafts.php";
		$.post(url,
		{ 'user_id':user_id,'page':page,'pro_subcategory': pro_subcategory, 'pro_sub_subcategory':pro_sub_subcategory, 'pro_name':pro_name,'pro_description':pro_description,'pro_price':pro_price,'bargain_price_option':bargain_price_option,'pro_courior':pro_courior,'pro_ship':pro_ship,'ship_status':ship_status,'localPickup':localPickup,'pro_commission':pro_commission,'bargain_commission_option':bargain_commission_option,'pro_quantity':pro_quantity,'pro_condition':pro_condition,'sales_tax':sales_tax,'pro_policy':pro_policy,'remarks':remarks,'amazon_name':amazon_name,'gift_name':gift_name,'gift_description':gift_description},
		function(data)
		{
			var temp = data.split('###');
			if(temp[1]=='succ')
			{
				$('#draft_box').html(temp[0]).show();
				alert("Saved to Drafts Successfully");
			}
			else
				alert("Sorry! Could not save at this time.");
		},
		'html');
	   }
}


function applyDraft(draft_id)
{
	//alert('hi');
	var url = "<?php echo $base_url;?>ajax_get_drafts.php";
	$.post(url,
	{ 'draft_id':draft_id},
	function(data)
	{
		//alert('hi');
		if(data!='')
		{
			var temp = data.split('###');
			
			
			
			
			$('#pro_name').val(temp[1]);
			
			$('#pro_price').val(temp[3]);
			format_value('pro_price');
			$('#bargain_price_option').val(temp[4]);
			toggle_bargain_img(temp[4]);
			
			$('#pro_courior').val(temp[5]);
			$('#pro_ship').val(temp[6]);
			
			if(temp[7]==1)
				$('#ship_status').attr('checked','checked');
			else
				$('#ship_status').attr('checked','');
			if(temp[8]==1)	
				$('#localPickup').attr('checked','checked');
			else
				$('#localPickup').attr('checked','');
				
			$('#pro_commission').val(temp[9]);
			format_value('pro_commission');
			$('#bargain_commission_option').val(temp[10]);
			toggle_bargain_c_img(temp[10]);
			
			$('#pro_quantity').val(temp[11]);
			$('#pro_condition').val(temp[12]);
			//alert(temp[13]);
			$('#sales_tax').val(temp[13]);
			$('#pro_policy').val(temp[14]);
			$('#remarks').val(temp[15]);
			$('#amazon_name').val(temp[16]);
			$('#gift_name').val(temp[17]);
			$('#gift_description').val(temp[18]);
			projected_profit();
			
			if(temp[19]!=1)
			{
				$('#pro_subcategory').val(temp[19]);
				
				getSubSubCat(temp[19],'sub-sub-category');
				setTimeout('$("#pro_sub_subcategory").val('+temp[0]+')',3000);
			}
			else
			{	
				$('#pro_subcategory').val(temp[0]);
				getSubSubCat(temp[19],'sub-sub-category');
			}
			//$("#pro_description").htmlarea("pasteHTML", "");
			$("#pro_description").htmlarea("pasteHTML", temp[2]);
			
			
		}
	},
	'html');
}
function show_preview()
{
	if (!validateForm())
	{
		//alert('fsdfsdfd');
	}
	else
	{

	var pro_subcategory = $('#pro_subcategory').val();
	var pro_sub_subcategory = $('#pro_sub_subcategory').val();
	var pro_name = $('#pro_name').val();
	var pro_description = $("#pro_description").htmlarea("toHtmlString");
	var pro_price = $('#pro_price').val();
	var bargain_price_option = $('#bargain_price_option').val();
	var pro_courior = $('#pro_courior').val();
	var pro_ship = $('#pro_ship').val();
	var ship_status = $('#ship_status').val();
	var localPickup = $('#localPickup').val();
	var pro_commission = $('#pro_commission').val();
	var bargain_commission_option = $('#bargain_commission_option').val();
	var pro_quantity = $('#pro_quantity').val();
	var pro_condition = $('#pro_condition').val();
	var sales_tax = $('#sales_tax').val();
	var pro_policy = $('#pro_policy').val();
	var remarks = $('#remarks').val();
	var amazon_name = $('#amazon_name').val();
	var gift_name = $('#gift_name').val();
	var gift_description = $('#gift_description').val();
	var page = 'sell_product';
	var user_id = '<?php echo $_SESSION['user_id_sess'];?>';
	
	openWindow('<?php echo $base_url;?>preview_product.php?pro_subcategory='+pro_subcategory+'&pro_sub_subcategory='+pro_sub_subcategory+'&pro_name='+pro_name+'&pro_description='+pro_description+'&pro_price='+pro_price+'&bargain_price_option='+bargain_price_option+'&pro_courior='+pro_courior+'&pro_ship='+pro_ship+'&ship_status='+ship_status+'&localPickup='+localPickup+'&pro_commission='+pro_commission+'&bargain_commission_option='+bargain_commission_option+'&pro_quantity='+pro_quantity+'&pro_condition='+pro_condition+'&sales_tax='+sales_tax+'&pro_policy='+pro_policy+'&remarks='+remarks+'&gift_name='+gift_name+'&gift_description='+gift_description+'','900','650');
	
	}
}

function show_helpBox1()
  {
    var help_pos = $('#help').position();
    //alert(help_pos.left+" "+help_pos.top);
    var new_left = parseInt(help_pos.left) - 100;
    var new_top = parseInt(help_pos.top) + 28;
    $('#help_drop_down1').css({'left': new_left, 'top':new_top});
    $('#help_drop_down1').slideDown('slow');
  }
</script>
<div id="help_drop_down1" class="help_popup">
  <span onclick="$('#help_drop_down1').slideUp('slow');">x</span>
  <ul>
  <li><a href="<?php echo $base_url;?>index.php?about#abt">About</a></li>
  <li><a href="<?php echo $base_url;?>index.php?contact#cnt">Contact us</a></li>
  <li><a href="<?php echo $base_url;?>index.php?faq#faq">FAQ</a></li>
  <li><a href="<?php echo $base_url;?>index.php?agreement#agr">Agreemens</a></li>
  <li><a href="<?php echo $base_url;?>index.php?resolution#rsl">Resolution Center</a></li>
  <li><a href="<?php echo $base_url;?>index.php?policy#plcy">Privacy Policy</a></li>
  </ul>
</div>

<script language="javascript" type="text/javascript">
function isInteger(s) {
  if (s.toString().search(/^-?[0-9]+$/) == 0)
  {}
  else
  {
  alert('quantity must be integer');
  }
}
</script>
<?php } ?>